@extends('admin.layouts.application')

@section('title')
    <title>投注管理</title>
@stop
@section('css')
    <link href="/assets/admin/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
@stop
@section('content')
    <div class="wrapper wrapper-content animated fadeInRight">
        {{--<div class="row" style="margin-left: 1rem;">--}}
        {{--<div class="col-sm-8 m-b-xs">--}}
        {{--<a href="{{route('admin.betting.create')}}" class="btn btn-primary">添加投注</a>--}}
        {{--</div>--}}
        {{--</div>--}}
        @include('edu.layouts.msg')
        <form class="form-horizontal m-t" action="{{route('admin.betting.store')}}"
              method="post">
            {{csrf_field()}}
            <div class="">
                {{--<label class="col-sm-1"></label>--}}
                <div class="col-sm-1">
                    <select name="type_id" id="" class="form-control m-b">
                        @foreach($types as $type)
                            <option value="{{$type->id}}">{{$type->name}}</option>
                        @endforeach
                    </select>
                </div>
            </div>
            <div class="">
                {{--<label class="col-sm-1"></label>--}}
                <div class="col-sm-1">
                    <select name="user_id" id="" class="form-control m-b">
                        <option value="1000">空</option>
                        @foreach($users as $user)
                            <option value="{{$user->id}}">{{$user->name}}</option>
                        @endforeach
                    </select>
                </div>
            </div>
            <div class="">
                <label class="col-sm-1 control-label">名称：</label>
                <div class="col-sm-1">
                    <input value="" name="name" class="form-control"
                           type="text">
                </div>
            </div>
            <div class="">
                <label class="col-sm-1 control-label">赔率：</label>
                <div class="col-sm-1">
                    <input value="0" id="temporary" min="1" name="temporary" class="form-control"
                           type="number">
                </div>
            </div>

            <div class="">
                <label class="col-sm-1 control-label">金额：</label>
                <div class="col-sm-1">
                    <input id="price" value="" min="100" max="2000000" required name="price" class="form-control"
                           type="number">
                </div>
            </div>
            <div class="">
                <label class="col-sm-1 control-label">备注：</label>
                <div class="col-sm-1">
                    <input value="" name="des" class="form-control"
                           type="text">
                </div>
            </div>
            <div class="">
                <div class="1">
                    <button class="btn btn-primary" type="submit">
                        提交
                    </button>
                </div>
            </div>
        </form>

        <form class="form-horizontal m-t" action="{{route('admin.match.store')}}"
              method="post">
            {{csrf_field()}}
            添加比赛结果
            <div class="">
                <label class="col-sm-1 control-label">主队：</label>
                <div class="col-sm-1">
                    <input value="" min="1" max="20" required name="main" class="form-control"
                           type="text">
                </div>
            </div>
            <div class="">
                <label class="col-sm-1 control-label">客队：</label>
                <div class="col-sm-1">
                    <input value="" required name="guest" class="form-control"
                           type="text">
                </div>
            </div>
            <div class="">
                <div class="col-sm-1 ">
                    <button class="btn btn-primary" type="submit">
                        提交
                    </button>
                </div>
            </div>
        </form>

        <form class="" action="{{route('admin.match.store')}}"
              method="post">
            {{csrf_field()}}
            <div class="col-sm-2">
                <label>
                    <p class="col-sm-6">主开：</p>
                    <div class="col-sm-1">
                        <input type="radio" style="width: 100px" name="kaiqiu" value="main">
                    </div>
                </label>
            </div>
            <div class="col-sm-2">
                <lable>
                    <label class="col-sm-6 control-label">客开：</label>
                    <div class="col-sm-1">
                        <input type="radio" style="width: 100px;" name="kaiqiu" value="guest">
                    </div>
                </lable>
            </div>
            <div class="">
                <div class="col-sm-1 ">
                    <button class="btn btn-primary" type="submit">
                        提交
                    </button>
                </div>
            </div>
        </form>

        <div class="col-sm-12" style="padding-top: 1rem">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>列表</h5>
                </div>
                <div class="ibox-content">
                    <div id="DataTables_Table_0_wrapper" class="dataTables_wrapper form-inline" role="grid">

                        <table class="table table-striped table-bordered table-hover dataTables-example dataTable"
                               id="DataTables_Table_0" aria-describedby="DataTables_Table_0_info">
                            <thead>
                            <tr role="row">
                                <th tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1"
                                    style="">所属人
                                </th>
                                <th tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1"
                                    style="">投注人
                                </th>
                                <th tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1"
                                    style="">投注类型
                                </th>
                                {{--<th tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1"--}}
                                {{--style="">赔率--}}
                                {{--</th>--}}
                                <th tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1"
                                    style="">临时赔率
                                </th>
                                <th tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1"
                                    style="">投注金额
                                </th>
                                <th tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1"
                                    style="">比赛结果
                                </th>
                                <th tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1"
                                    style="">盈利
                                </th>
                                <th tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1"
                                    style="">添加时间
                                </th>
                                <th tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1"
                                    style="">
                                    操作
                                </th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($bettings as $rv)
                                @if(is_object($rv))
                                    <tr class="gradeA odd">
                                        <td>{{$rv->p_name}}</td>
                                        <td>{{$rv->user_name}}</td>
                                        <td>{{$rv->type_name}}</td>
                                        {{--<td>{{$rv->type_num}}</td>--}}
                                        <td>{{$rv->temporary==0?'未使用临时赔率':$rv->temporary}}</td>
                                        <td>{{$rv->price}}</td>
                                        <td>{{$rv->score}}</td>
                                        <td>{{$rv->result}}</td>
                                        <td>{{substr($rv->create_time,0,10)}}</td>
                                        <td>
                                            <a data-id="{{$rv->id}}" href="{{route('admin.betting.update',$rv->id)}}"
                                               class="label label-danger delete">
                                                <i class="fa fa-trash"></i> 修改</a>
                                        </td>
                                    </tr>
                                @endif
                            @endforeach
                            </tbody>
                            <p>客户总投注:{{$res[0]['sum_price']}},
                                客户总盈利:{{$res[0]['sum_result']}},
                                客户盈利为负数，转为正数即庄家所赚。
                            </p>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
@section('js')
    <!-- Data Tables -->
    <script src="/assets/admin/js/plugins/dataTables/jquery.dataTables.js"></script>
    <script>
        $('#price').css('width', '80px');
        $('#temporary').css('width', '80px');
    </script>
    <!-- Page-Level Scripts -->
    <script>
        $(document).ready(function () {
            $('.dataTables-example').dataTable({'ordering': false});
        });
    </script>
@stop